<?xml version="1.0" encoding="UTF-8"?>
 <grammar xmlns="http://relaxng.org/ns/structure/1.0">
  <start>
   <ref name="element-library"/>
  </start>
  <define name="element-library">
   <element name="library">
    <oneOrMore>
     <ref name="element-book"/>
    </oneOrMore>
   </element>
  </define>
  <define name="element-book">
   <element name="book">
    <ref name="book-basic"/>
    <ref name="book-extended"/>
   </element>
  </define>
  <define name="book-basic">
   <attribute name="id"/>
   <ref name="element-isbn"/>
   <ref name="element-title"/>
   <oneOrMore>
    <ref name="element-author"/>
   </oneOrMore>
   <optional>
    <ref name="element-character"/>
   </optional>
  </define>
  <define name="book-extended">
   <attribute name="available"/>
   <zeroOrMore>
    <ref name="element-character"/>
   </zeroOrMore>
  </define>
  <define name="element-isbn">
   <element name="isbn">
    <text/>
   </element>
  </define>
  <define name="element-title">
   <element name="title">
    <attribute name="xml:lang"/>
    <text/>
   </element>
  </define>
  <define name="element-author">
   <element name="author">
    <attribute name="id"/>
    <ref name="element-name"/>
    <optional>
     <ref name="element-born"/>
    </optional>
    <optional>
     <ref name="element-died"/>
    </optional>
   </element>
  </define>
  <define name="element-name">
   <element name="name">
    <text/>
   </element>
  </define>
  <define name="element-born">
   <element name="born">
    <text/>
   </element>
  </define>
  <define name="element-died">
   <element name="died">
    <text/>
   </element>
  </define>
  <define name="element-character">
   <element name="character">
    <attribute name="id"/>
    <ref name="element-name"/>
    <optional>
     <ref name="element-born"/>
    </optional>
    <ref name="element-qualification"/>
   </element>
  </define>
  <define name="element-qualification">
   <element name="qualification">
    <text/>
   </element>
  </define>
 </grammar>
